package com.wcarmon.life.command{

    import com.adobe.cairngorm.commands.ICommand
    import com.adobe.cairngorm.control.CairngormEvent;
	import mx.controls.Alert;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.IResponder;
	import com.wcarmon.life.model.LifeModelLocator;
	import com.wcarmon.life.event.*;
	import com.wcarmon.life.business.*;
	import com.wcarmon.life.vo.*;
	import mx.utils.ObjectUtil;
	import mx.collections.*;
	
	public class DoImapImportCommand implements ICommand, IResponder {
		include "../../includes/loggerSnippet.as";
			
		public function execute( event : CairngormEvent ) : void { 
			//var e : DoImapImportEvent = DoImapImportEvent( event );
			( new DoImapImportDelegate(this) ).doImport();
		}
	
	 	public function result( event : Object ) : void {
			var e : ResultEvent = ResultEvent(event);
			var model : LifeModelLocator = LifeModelLocator.getInstance();
			
			Alert.show( "Imap import result: \n"+ e.result );
			Alert.show("imported "+ e.result.numMessagesImported +" items from IMAP inbox.");
			( new UpdateStatsEvent() ).dispatch();
		}
	
		public function fault( event : Object ) : void {
			include "includes/FaultSnippet.as";
		}
	}
}